<?php
namespace app\appadmin\controller\v1;
use app\app\Appbase;

class Hflog extends Appbase 
{	
	/**
	*回访列表
	* /appadmin/v1/hflog/index
	* 需要登录 
	* @is_need_login true
	*/
	public function index($uid='',$staff_id=''){
		$shopId = request()->shopId;
		try {
			$model = model('UserHfLog');
			$model = $model->with(['project']);
	      	$model = $model->where('shop_id',$shopId);
			$uid && $model = $model->where('uid',$uid);
			$staff_id && $model = $model->where('hf_id',$staff_id);
			$model = $model->page(input('pageIndex') ?: 1,input('pageSize') ?: 20);
			$result = $model->select();
			return $this->ReSucess($result);	
		} catch (\Exception $e) {
			throw new \think\Exception( $e );
		}
	}
	
	
	/**
	*回访列表
	* /appadmin/v1/hflog/add
	* 需要登录 
	* @is_need_login true
	* @method post
	*/
	public function create(){
		try {  
			$param = request()->post();
			$param['shop_id']  =request()->shopId;
			$param['hf_id']  =request()->userId;
			$param['hf_name']  =request()->userName;
			$res = model('UserHfLog')->save($param);
			return $this->ReSucess($res);	
		} catch (\Exception $e) {
			return $this->ReError($e->getMessage());	
		}
	}
	
}



